package com.elh.jpa.model;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

@Entity
@Table(name = "orders")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Orders {
  private String orderNumber;
  private double initialPrice;
  private double price;
  private LocalDate startTime;
  private LocalDate endTime;
  private String status;
  private String userId;
  private String details;
  private Map<String,Object> mapDetails;

  public static void main(String[] args) {
      Map<String,Object> data = new HashMap<>();
      data.put("name","liulei");
      data.put("age",1);
      Map<String,Object> map = new HashMap<>();
      Map<String,Object> mapDetails = new HashMap<>();
      map.put("m1","99");
      map.put("m2",100);

      mapDetails.put("ll","0988");
      data.put("map",map);
      data.put("m",map);
      data.put("mapDetails",mapDetails);
      Orders orders = new Orders();
      orders.setMapDetails(data);
//      orders.setDetails(JSONObject.toJSONString(data));
      System.out.println(JSONObject.toJSONString(orders));
  }


}